class Ruiqu::StoreOrdersController < Ruiqu::BaseController
  before_action :set_search_params, only: [:index]
  def index
    @q = current_store.orders.order("id desc").ransack(params[:q])
    @store_orders = @q.result.page(params[:page])
  end

  private
  def set_search_params
    params[:q] ||= {}
    @company_name = params[:q][:company_name_cont]
    @numero = params[:q][:numero_cont]
    @phone_number = params[:q][:phone_number_cont]
    @status = params[:q][:status_eq]
    @pay_status = params[:q][:pay_status_eq]
    @start = params[:q][:created_at_gteq]
    @end = params[:q][:created_at_lteq]
    params[:q][:created_at_lteq] = params[:q][:created_at_lteq].to_date.end_of_day if params[:q][:created_at_lteq].present?
  end
end
